#include "common.h"

void shellSort(int array[], int n);

void main()
{
    int array[] = {6, 5, 4, 3, 2, 1};
    int len = 6;
    shellSort(array, len);
    print(array, len);
}

void shellSort(int array[], int n)
{
    int d, i, j, temp;
    for (d = n / 2; d >= 1; d = d / 2)
    {
        for (i = d; i < n; i++)
        {
            if (array[i] < array[i - d])
            {
                temp = array[i];
                for (j = i - d; j >= 0 && temp < array[j]; j = j - d)
                {
                    array[j + d] = array[j];
                }
                array[j + d] = temp;
            }
        }
    }
}
